﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Collections;

namespace B2B.Models
{
    public class DanhMuc
    {
        private int maDanhMuc;

        public int MaDanhMuc
        {
            get { return maDanhMuc; }
            set { maDanhMuc = value; }
        }
        private string tenDanhMuc;

        public string TenDanhMuc
        {
            get { return tenDanhMuc; }
            set { tenDanhMuc = value; }
        }
        private int maLinhVuc;

        public int MaLinhVuc
        {
            get { return maLinhVuc; }
            set { maLinhVuc = value; }
        }

        public List<DanhMuc> DanhSachDanhMuc(int id)
        {
            List<DanhMuc> list_DanhMuc = new List<DanhMuc>();
            SqlConnection conn = KetNoi.Connection();
            SqlCommand cmd = new SqlCommand("SP_DANHSACHDANHMUC", conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@maLinVuc", id);            
            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                DanhMuc dm = new DanhMuc();
                dm.MaDanhMuc = reader.GetInt32(0);
                dm.TenDanhMuc = reader.GetString(1);
                list_DanhMuc.Add(dm);
            }
            conn.Close();
            return list_DanhMuc;
        }
   
    }
}